﻿using System;
using System.Net;
using System.Net.Sockets;

namespace IPAddressesExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Local host: " + Dns.GetHostName());

            Console.WriteLine("\nGoogle host info: ");
            GetIPInfo("www.google.com");
        }

        private static void GetIPInfo(string host)
        {           
            IPHostEntry hostInfo;            

            hostInfo = Dns.GetHostEntry(host);

            Console.WriteLine("Canonocal name: " + hostInfo.HostName);

            Console.WriteLine("\nList of addresses: ");
            foreach (var address in hostInfo.AddressList)
            {
                Console.WriteLine(address);
            }

            Console.WriteLine("\nAliases: ");

            foreach (var alias in hostInfo.Aliases)
            {
                Console.WriteLine(alias);
            }
        }
    }
}
